from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import config
from datetime import datetime
from werkzeug.security import generate_password_hash, check_password_hash

app = Flask(__name__)
app.config.from_object(config)
db = SQLAlchemy(app)


class BaseModel(object):
    create_time = db.Column(db.DateTime, default=datetime.now)
    update_time = db.Column(db.DateTime)
    isDelete = db.Column(db.Boolean, default=True)


class UserInfo(db.Model, BaseModel):
    __tablename__ = 'user_info'
    id = db.Column(db.Integer, primary_key=True)
    user_name = db.Column(db.String(20))
    mobile = db.Column(db.String(11))
    id_card = db.Column(db.String(200))
    pwd = db.Column(db.String(200))
    create_time = db.Column(db.DateTime, default=datetime.now)
    update_time = db.Column(db.DateTime)
    isDelete = db.Column(db.Boolean, default=True)


class AdminInfo(db.Model, BaseModel):
    __tablename__ = 'admin_info'
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(50))
    password = db.Column(db.String(50))


class CovInfo(db.Model, BaseModel):
    __tablename__ = 'cov_info'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50))
    phone = db.Column(db.String(50))
    temperature = db.Column(db.String(50))
    currentProvince = db.Column(db.String(50))
    currentCity = db.Column(db.String(50))
    currentCounty = db.Column(db.String(50))
    currentDetail = db.Column(db.String(255))
    is_fever_cough_1 = db.Column(db.String(10))
    is_fever_cough_2 = db.Column(db.String(10))
    is_fever_cough_3 = db.Column(db.String(10))
    is_fever_cough_0 = db.Column(db.String(10))
    is_covid = db.Column(db.String(10))
    is_infection = db.Column(db.String(10))
    area_level = db.Column(db.String(10))
    is_health_code = db.Column(db.String(10))
    is_back_foreign = db.Column(db.String(10))
    is_touch_foreigner = db.Column(db.String(10))
    description = db.Column(db.String(255))
    create_time = db.Column(db.DateTime, default=datetime.now)
    update_time = db.Column(db.DateTime)
    isDelete = db.Column(db.Boolean, default=True)
